<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_controller {

    public function index($data = array()) {
		// construct the parent
		parent::__construct();
		
        // TODO: check if the user is logged in
        $this->load->view('login', $data);
    }

    public function user_login() {
        $this->load->model('login_model');
        $user = $this->login_model->validate();

        if ($result) {
			$username = $this->input->post('username');
			
            $data = array(
                'username' => $username,
                'logged_in' => true,
				'user_email' => $email
            );

			// set some userdata in the session
            $this->session->set_userdata($data);
			
            redirect('admin');
        } else {
			// set some data
			$data = array('error' => 'Gebruikersnaam en/of wachtwoord is niet goed');
			
            $this->index($data);
        }
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */